{{extend "layout.html"}}
<div id='mapHolder' style='width:100%; height: 100%; border: 1px solid black'>
 If you see this message you need to install Flash Player 10.1.85 or above, from Adobe, <a href="http://get.adobe.com/flashplayer/" target="_blank">available here</a> in order to use Potlatch 2
</div>
<script type="text/javascript" src="/{{=appname}}/static/potlatch2/swfobject.js"></script>
<script>
function getArgs() {
 var args = new Object();
 var query = location.search.substring(1);
 var pairs = query.split('&');
 for(var i = 0; i < pairs.length; i++) {
  var pos = pairs[i].indexOf('=');
  if (pos == -1) continue;
  var argname = pairs[i].substring(0,pos);
  var value = pairs[i].substring(pos+1);
  args[argname] = unescape(value);
 }
 return args;
}
var changesaved=true;
window.onbeforeunload=function() {
 if (!changesaved) {
  return '{{=T("You have unsaved changes. You need to press the Save button to save them")}}';
 }
}
function markChanged(a) {changesaved=a;} /* called from flash */
var attributes = {
 id:'map',
 name:'map'
};
var args=getArgs();
var lat;
var lon;
var zoom;
if (args.lat && args.lon) {
 lat=parseFloat(args.lat);
 lon=parseFloat(args.lon);
} else {
 lat=51.875;
 lon=-1.492;
}
if (args.zoom) {
 zoom=parseInt(args.zoom);
} else {
 zoom=16;
}
args['lat'] = lat;
args['lon'] = lon;
args['zoom'] = zoom;
args['api'] = 'http://www.openstreetmap.org/api/0.6/';
args['policy'] = 'http://www.openstreetmap.org/api/crossdomain.xml';
args['connection'] = 'XML';
args['oauth_policy'] = 'http://www.openstreetmap.org/oauth/crossdomain.xml';
args['oauth_request_url'] = 'http://www.openstreetmap.org/oauth/request_token';
args['oauth_access_url'] = 'http://www.openstreetmap.org/oauth/access_token';
args['oauth_auth_url'] = 'http://www.openstreetmap.org/oauth/authorize';
args['oauth_consumer_key'] = '{{=key}}';
args['oauth_consumer_secret'] = '{{=secret}}';
args['serverName'] = 'OpenStreetMap';
args['show_help'] = 'once';
args['site_name'] = '{{=site_name}}';
args['force_auth'] = 'force';
{{if gpx_url:}}
 args['gpx_url'] = '{{=gpx_url}}'; // automatically loads a GPX file
{{pass}}
{{if s3.language == 'en_GB':}}
 args['locale'] = 'en_GB';
{{elif s3.language == 'fr':}}
 args['locale'] = 'fr_FR'; 
{{elif s3.language == 'de':}}
 args['locale'] = 'de_DE';
{{pass}}
var params = {};
params['base'] = '/{{=appname}}/static/potlatch2/';
swfobject.embedSWF('/{{=appname}}/static/potlatch2/potlatch2.swf?d='+Math.round(Math.random()*1000), 'mapHolder', '100%', '650px', '10.1.85', '/{{=appname}}/static/potlatch2/expressInstall.swf', args, params, attributes);
</script>
